package one.stand.service.impl;

import com.fasterxml.jackson.databind.util.BeanUtil;
import one.stand.model.ResultModel;
import one.stand.model.WxNoticeModel;
import one.stand.request.SubRequest;
import one.stand.response.SubscriptionNewResponse;
import one.stand.service.BaseService;
import one.stand.service.SubscriptionService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 订阅消息业务实现类
 */
@Service
@Transactional
public class SubscriptionServiceImpl extends BaseService implements SubscriptionService {

    /**
     * 查询公司模板
     * @param subRequest
     * @return
     */
    @Override
    public ResultModel<List<SubscriptionNewResponse>> getCompanyNotice(SubRequest subRequest){
        WxNoticeModel wxNoticeModel = new WxNoticeModel();
        BeanUtils.copyProperties(subRequest,wxNoticeModel);
        //查询名片订阅消息
        wxNoticeModel.setMsgType(2);
        wxNoticeModel.setType("USER");
        //todo 待处理bug 订阅消息主体没有按小程序主体来 目前按公司来。固定一个公司为小程序主体。这样这样小程序下面的所有公司才可以使用
        log.info("getCompanyNotice:{},subRequest:{}",wxNoticeMapper.getCompanyNotice(wxNoticeModel),subRequest);
        return ResultModel.success(wxNoticeMapper.getCompanyNotice(wxNoticeModel));
    }
}
